package com.gw.detail.controllor.detail;

import com.gw.detail.domain.Kbadaten;
import com.gw.detail.service.IKbadatenService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 车辆注册参数数据Controller
 *
 * @author WangBin
 * @date 2021-04-30
 */
@RestController
@RequestMapping("/detail/kbadaten")
public class KbadatenController extends BaseController {
    @Autowired
    private IKbadatenService kbadatenService;

    /**
     * 查询车辆注册参数数据列表
     */
    @PreAuthorize("@ss.hasPermi('detail:kbadaten:list')")
    @GetMapping("/list")
    public TableDataInfo list(Kbadaten kbadaten) {
        startPage();
        List<Kbadaten> list = kbadatenService.selectKbadatenList(kbadaten);
        return getDataTable(list);
    }

    /**
     * 导出车辆注册参数数据列表
     */
    @PreAuthorize("@ss.hasPermi('detail:kbadaten:export')")
    @Log(title = "车辆注册参数数据", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Kbadaten kbadaten) {
        List<Kbadaten> list = kbadatenService.selectKbadatenList(kbadaten);
        ExcelUtil<Kbadaten> util = new ExcelUtil<Kbadaten>(Kbadaten.class);
        return util.exportExcel(list, "车辆注册参数数据数据");
    }

    /**
     * 获取车辆注册参数数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('detail:kbadaten:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(kbadatenService.selectKbadatenById(id));
    }

    /**
     * 新增车辆注册参数数据
     */
    @PreAuthorize("@ss.hasPermi('detail:kbadaten:add')")
    @Log(title = "车辆注册参数数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Kbadaten kbadaten) {
        return toAjax(kbadatenService.insertKbadaten(kbadaten));
    }

    /**
     * 修改车辆注册参数数据
     */
    @PreAuthorize("@ss.hasPermi('detail:kbadaten:edit')")
    @Log(title = "车辆注册参数数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Kbadaten kbadaten) {
        return toAjax(kbadatenService.updateKbadaten(kbadaten));
    }

    /**
     * 删除车辆注册参数数据
     */
    @PreAuthorize("@ss.hasPermi('detail:kbadaten:remove')")
    @Log(title = "车辆注册参数数据", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(kbadatenService.deleteKbadatenByIds(ids));
    }
}
